import request from 'umi-request';

export async function getScoreList(params,index) {
  return request('/api/member/api-member/member/getRaterPage', {
    method: 'post',
    data:{
      pageNum: params.current,
      pageSize: params.pageSize,
      status:index ? parseInt(index) : index
    },
    requestType: 'form'
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getScoreTopic(programId) {
  return request('/api/member/api-member/member/getTopicInfo', {
    method: 'post',
    data: {programId},
    requestType: 'form'
  }).then((res) => {
    if (res.flag) {
      return res.data;
    } else {
      return [];
    }
  });
}

export async function saveScoreInfo(params) {
  return request('/api/member/api-member/member/saveRaterTopicInfo', {
    method: 'post',
    data: {
      ...params,
    },
  }).then((res) => {
    return res;
  });
}

export async function queryScoreInfo(id) {
  return request('/api/member/api-member/member/getSoreTopicScore', {
    method: 'get',
    params: {
      id:id,
    },
  }).then((res) => {
    return res.data;
  });
}
